package com.suixinsanren.design.compound.study.demo02;

public class DuckSimulator {

    public static void main(String[] args) {
        DuckSimulator simulator = new DuckSimulator();
        simulator.simulator();
    }

    public void simulator() {
        Quackable mallardDuck = new QuackCounter(new MallardDuck());
        Quackable redHeadDuck = new QuackCounter(new RedHeadDuck());
        Quackable duckCall = new QuackCounter(new DuckCall());
        Quackable rubberDuck = new QuackCounter(new RubberDuck());
        GooseAdapter goose = new GooseAdapter(new Goose());

        System.out.println("--------Duck Simulator--------");

        simulator(mallardDuck);
        simulator(redHeadDuck);
        simulator(duckCall);
        simulator(rubberDuck);
        simulator(goose);

        System.out.println("The ducks quacked "+QuackCounter.getQuacks()+" times");
    }


    public void simulator(Quackable duck) {
        duck.quack();
    }
}
